home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / EXECUTC2.MOD < prev    next >
Text File  |  1987-09-03  |  42KB  |  1,077 lines

  1. (*----------------------------------------------------------------------*)
  2.  
  3. BEGIN (* Execute_Command *)
  4.                                    (* Save current state of important params *)
  5.  
  6.    Alter_Status        := FALSE;
  7.    Save_Do_Status_Line := Do_Status_Line;
  8.  
  9.                                    (* Don't get confused by previous *)
  10.                                    (* script strings if manual entry *)
  11.  
  12.    IF ( NOT ( Use_Script OR Script_Learn_Mode ) ) THEN
  13.       BEGIN
  14.          Script_String  [0]  := #0;
  15.          Script_String_2[0]  := #0;
  16.          Script_Integer_1    := 0;
  17.       END;
  18.                                    (* Execute chosen command *)
  19. {
  20.    CASE Command Of
  21. }
  22.                                    (* Use jump table to avoid time-consuming *)
  23.                                    (* CASE statement.                        *)
  24.    I := ORD( Command );
  25.  
  26.    INLINE(
  27.      $8B/$9E/>I             {  MOV     BX,[BP+>I]         ;Pick up ORD(Command)}
  28.      /$89/$D8               {  MOV     AX,BX              ;Command}
  29.      /$D1/$E3               {  SHL     BX,1               ;Command * 2}
  30.      /$01/$C3               {  ADD     BX,AX              ;Command * 3}
  31.      /$B8/>*+6              {  MOV     AX,>*+6            ;Address of first GOTO}
  32.      /$01/$C3               {  ADD     BX,AX              ;Add offset of command}
  33.      /$FF/$E3               {  JMP     BX                 ;Branch to proper GOTO}
  34.    );
  35.       GOTO LEndCase;
  36.       GOTO LAddLFSy;
  37.       GOTO LAlarmSy;
  38.       GOTO LAreaCodeSy;
  39.       GOTO LBreakSy;
  40.       GOTO LEndCase;
  41.       GOTO LCaptureSy;
  42.       GOTO LEndCase;
  43.       GOTO LChDirSy;
  44.       GOTO LClearSy;
  45.       GOTO LCloseSy;
  46.       GOTO LClrEolSy;
  47.       GOTO LCommFlushSy;
  48.       GOTO LDeclareSy;
  49.       GOTO LDelaySy;
  50.       GOTO LDelLineSy;
  51.       GOTO LDialSy;
  52.       GOTO LEndCase;
  53.       GOTO LDosSy;
  54.       GOTO LEchoSy;
  55.       GOTO LEditSy;
  56.       GOTO LEndCase;
  57.       GOTO LEndCase;
  58.       GOTO LEndCase;
  59.       GOTO LEndCase;
  60.       GOTO LEndCase;
  61.       GOTO LEndCase;
  62.       GOTO LEndCase;
  63.       GOTO LEndCase;
  64.       GOTO LExecuteSy;
  65.       GOTO LExeNewSy;
  66.       GOTO LExitSy;
  67.       GOTO LExitAllSy;
  68.       GOTO LFastCSy;
  69.       GOTO LFileSy;
  70.       GOTO LEndCase;
  71.       GOTO LGetDirSy;
  72.       GOTO LGetParamSy;
  73.       GOTO LGetVarSy;
  74.       GOTO LGossipSy;
  75.       GOTO LGoToSy;
  76.       GOTO LGoToXYSy;
  77.       GOTO LHangUpSy;
  78.       GOTO LHostSy;
  79.       GOTO LIfConSy;
  80.       GOTO LIfDialSy;
  81.       GOTO LIfEofSy;
  82.       GOTO LIfExistsSy;
  83.       GOTO LIfFoundSy;
  84.       GOTO LIfLocStrSy;
  85.       GOTO LIfOkSy;
  86.       GOTO LIfOpSy;
  87.       GOTO LIfRemStrSy;
  88.       GOTO LImportSy;
  89.       GOTO LInfoSy;
  90.       GOTO LInputSy;
  91.       GOTO LInsLineSy;
  92.       GOTO LKeyDefSy;
  93.       GOTO LKeyFlushSy;
  94.       GOTO LKeySendSy;
  95.       GOTO LKeySy;
  96.       GOTO LEndCase;
  97.       GOTO LLogSy;
  98.       GOTO LMenuSy;
  99.       GOTO LMessageSy;
  100.       GOTO LMuteSy;
  101.       GOTO LOpenSy;
  102.       GOTO LParamSy;
  103.       GOTO LPImportSy;
  104.       GOTO LEndCase;
  105.       GOTO LQuitSy;
  106.       GOTO LReadSy;
  107.       GOTO LReadLnSy;
  108.       GOTO LReceiveSy;
  109.       GOTO LReDialSy;
  110.       GOTO LEndCase;
  111.       GOTO LResetSy;
  112.       GOTO LReturnSy;
  113.       GOTO LRInputSy;
  114.       GOTO LScriptSy;
  115.       GOTO LSDumpSy;
  116.       GOTO LSendSy;
  117.       GOTO LSetSy;
  118.       GOTO LSetParamSy;
  119.       GOTO LSetVarSy;
  120.       GOTO LSTextSy;
  121.       GOTO LEndCase;
  122.       GOTO LTextSy;
  123.       GOTO LTimersSy;
  124.       GOTO LTranslateSy;
  125.       GOTO LEndCase;
  126.       GOTO LViewSy;
  127.       GOTO LWaitSy;
  128.       GOTO LEndCase;
  129.       GOTO LEndCase;
  130.       GOTO LEndCase;
  131.       GOTO LEndCase;
  132.       GOTO LEndCase;
  133.       GOTO LEndCase;
  134.       GOTO LEndCase;
  135.       GOTO LEndCase;
  136.       GOTO LWhereXYSy;
  137.       GOTO LEndCase;
  138.       GOTO LWriteSy;
  139.       GOTO LWriteLnSy;
  140.       GOTO LWriteLogSy;
  141.       GOTO LZapVarSy;
  142.       GOTO LEndCase;
  143.       GOTO LEndCase;
  144.  
  145.       LAddLFSy    :  BEGIN
  146.                         Toggle_Option( 'Add line feeds', Add_LF );
  147.                         Alter_Status := TRUE;
  148.                      END;
  149.                      GOTO LEndCase;
  150.  
  151.       LAlarmSy    :  FOR I := 1 TO 5 DO
  152.                         BEGIN
  153.                            Menu_Beep;
  154.                            DELAY( 3 * Tenth_Of_A_Second_Delay );
  155.                         END;
  156.                      GOTO LEndCase;
  157.  
  158.       LAreaCodeSy :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  159.                         GetAreaCode;
  160.                      GOTO LEndCase;
  161.  
  162.       LBreakSy    :  BEGIN
  163.                         Async_Send_Break;
  164.                         IF Script_Learn_Mode THEN
  165.                            BEGIN
  166.                               IF ( LENGTH( Script_String ) > 0 ) THEN
  167.                                  WRITELN( Script_File , 'SText "', Script_String, '"' );
  168.                               Script_String[0]        := #0;
  169.                               Script_Learn_Line_Count := 0;
  170.                               Script_Wait_Generated   := FALSE;
  171.                               WRITELN( Script_File , 'Break' );
  172.                            END;
  173.                         GOTO LEndCase;
  174.                      END;
  175.  
  176.       LCaptureSy  :  BEGIN
  177.                         IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  178.                            Get_Capture_File( Script_String , Script_String_2 );
  179.                            Alter_Status := TRUE;
  180.                      END;
  181.                      GOTO LEndCase;
  182.  
  183.       LChDirSy    :  Dir_Set_Default_Drive( Script_String_2[1] );
  184.                      Script_IO_Error := Dir_Set_Current_Path( Script_String );
  185.                      GOTO LEndCase;
  186.  
  187.       LClearSy    :  Clear_Window;
  188.                      GOTO LEndCase;
  189.  
  190.       LCloseSy    :  BEGIN
  191.  
  192.                         IF ( ( Script_Integer_1 < 1 ) OR
  193.                              ( Script_Integer_1 > MaxScriptOpenFiles ) ) THEN
  194.                            BEGIN
  195.                               Script_IO_Error := 999;
  196.                               GOTO LEndCase;
  197.                            END;
  198.  
  199.                         IF Script_File_Used[Script_Integer_1] THEN
  200.                            BEGIN
  201.                               IF Script_File_List[Script_Integer_1]^.Opened THEN
  202.                                  BEGIN
  203.                                        (*$I-*)
  204.                                     CLOSE( Script_File_List[Script_Integer_1]^.F );
  205.                                        (*$I+*)
  206.                                     Script_IO_Error := INT24Result;
  207.                                  END;
  208.                               DISPOSE( Script_File_List[Script_Integer_1] );
  209.                               Script_File_Used[Script_Integer_1] := FALSE;
  210.                            END;
  211.  
  212.                         GOTO LEndCase;
  213.  
  214.                      END;
  215.  
  216.       LClrEolSy   :  ClrEol;
  217.                      GOTO LEndCase;
  218.  
  219.       LCommFlushSy:  Async_Purge_Buffer;
  220.                      GOTO LEndCase;
  221.  
  222.       LPImportSy  :
  223.       LImportSy   :
  224.       LDeclareSy  :  Allocate_Variable;
  225.                      GOTO LEndCase;
  226.  
  227.       LDelaySy    :  DELAY( Delay_Time );
  228.                      GOTO LEndCase;
  229.  
  230.       LDelLineSy  :  DelLine;
  231.                      GOTO LEndCase;
  232.  
  233.       LDialSy     :
  234.       LReDialSy   :  BEGIN
  235.                         T_Type := Terminal_To_Emulate;
  236.                         IF MyLoadOverlay( 0 , PT4DIAL, 'PT4DIAL.CHN' ) THEN
  237.                            PibDialer( ( Command = ReDialSy ) , Script_String ,
  238.                                       ( Script_Integer_1 = 0 ) );
  239.                         Script_String[0] := #0;
  240.                         Done             := ( Terminal_To_Emulate <> T_Type );
  241.                         IF Read_In_Script THEN
  242.                            BEGIN
  243.                               Read_In_Script   := FALSE;
  244.                               IF MyLoadOverlay( 0 , PT4SCRI, 'PT4SCRI.CHN' ) THEN
  245.                                  Process_Script( Script_File_Name , 'E');
  246.                            END;
  247.                         Alter_Status := TRUE;
  248.                         GOTO LEndCase;
  249.                      END;
  250.  
  251.       LDosSy      :  BEGIN
  252.                         DosJump( Script_String );
  253.                         Script_String[0] := #0;
  254.                         GOTO LEndCase;
  255.                      END;
  256.  
  257.       LEchoSy     :  BEGIN
  258.                         Toggle_Option( 'Local Echo', Local_Echo );
  259.                         Alter_Status := TRUE;
  260.                      END;
  261.                      GOTO LEndCase;
  262.  
  263.       LEditSy     :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  264.                         Edit_A_Line;
  265.                      GOTO LEndCase;
  266.  
  267.       LExitSy     :  IF Script_File_Mode THEN
  268.                         BEGIN
  269.  
  270.                            Alter_Status := TRUE;
  271.  
  272.                            IF ( Script_Stack_Depth = 0 ) THEN
  273.                              BEGIN
  274.                                  IF Script_Command_Key_Mode THEN
  275.                                     BEGIN
  276.                                        Script_Command_Key_Mode := FALSE;
  277.                                        Script_File_Mode        := FALSE;
  278.                                     END
  279.                                  ELSE
  280.                                     BEGIN
  281.                                        IF Auto_Unload_Scripts THEN
  282.                                           Unload_This_Script;
  283.                                        Toggle_Option( 'Script Mode', Script_File_Mode );
  284.                                     END;
  285.                                  Clear_Script_Variables;
  286.                               END
  287.                            ELSE
  288.                               BEGIN
  289.  
  290.                                  IF Auto_Unload_Scripts THEN
  291.                                     Unload_This_Script;
  292.  
  293.                                    (* Free space for variable values *)
  294.  
  295.                                  Zap_Script_Variables( 3 ,
  296.                                                        Script_Variable_Count );
  297.  
  298.                                    (* Free space for variable pointers *)
  299.  
  300.                                  FREEMEM( Script_Variables ,
  301.                                           ( Script_Variable_Count + 3 ) * SizeOf( Script_Variables^[1] ) );
  302.  
  303.                                    (* Free space for any parameters *)
  304.  
  305.                                  IF ( Script_Parameter_Count > 0 ) THEN
  306.                                     DISPOSE( Script_Parameters );
  307.  
  308.                                  WITH Script_Stack_Position[Script_Stack_Depth] DO
  309.                                     BEGIN
  310.                                        Script_Buffer          := Buffer_Ptr;
  311.                                        Script_Buffer_Pos      := Buffer_Pos;
  312.                                        Current_Script_Num     := Script_Num;
  313.                                        Script_Variables       := Vars_Ptr;
  314.                                        Script_Variable_Count  := Vars_Count;
  315.                                        Script_Parameters      := Params_Ptr;
  316.                                        Script_Parameter_Count := Params_Count;
  317.                                        Script_Parameter_Got   := Params_Got;
  318.                                        Prev_Script_Variables  := Prev_Ptr;
  319.                                     END;
  320.                                  Script_Stack_Depth := PRED( Script_Stack_Depth );
  321.  
  322.                               END;
  323.  
  324.                         END;
  325.                      GOTO LEndCase;
  326.  
  327.       LExitAllSy  :  BEGIN
  328.                         Exit_All_Scripts;
  329.                         Alter_Status := TRUE;
  330.                      END;
  331.                      GOTO LEndCase;
  332.  
  333.       LFastCSy    :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  334.                         Fast_Change_Params;
  335.                      GOTO LEndCase;
  336.  
  337.       LFileSy     :  REPEAT
  338.                         IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  339.                            BEGIN
  340.                               PibFileManipulation( File_Done  ,
  341.                                                    Do_Editing , Do_Viewing );
  342.                               IF Do_Editing THEN
  343.                                  BEGIN
  344.                                     IF ( LENGTH( Editor_Name ) > 0 ) THEN
  345.                                        BEGIN
  346.                                           IF ( POS( '%F' , Editor_Name ) > 0 ) THEN
  347.                                              Fix_Up_File_Name( 'Edit',
  348.                                                                Editor_Name,
  349.                                                                S )
  350.                                           ELSE
  351.                                              S := Editor_Name;
  352.                                           DosJump( S );
  353.                                        END
  354.                                     ELSE IF MyLoadOverlay( 0 , PT4EDIT, 'PT4EDIT.CHN' ) THEN
  355.                                        PibEditor
  356.                                  END
  357.                               ELSE IF Do_Viewing THEN
  358.                                  BEGIN
  359.                                     IF ( LENGTH( Browser_Name ) > 0 ) THEN
  360.                                        BEGIN
  361.                                           IF ( POS( '%F' , Browser_Name ) > 0 ) THEN
  362.                                              Fix_Up_File_Name( 'View',
  363.                                                                Browser_Name,
  364.                                                                S )
  365.                                           ELSE
  366.                                              S := Browser_Name;
  367.                                           DosJump( S );
  368.                                        END
  369.                                     ELSE
  370.                                        View_A_File;
  371.                                  END;
  372.                            END
  373.                         ELSE
  374.                            File_Done := TRUE;
  375.                      UNTIL( File_Done );
  376.                      GOTO LEndCase;
  377.  
  378.       LGetDirSy   :  BEGIN
  379.                         Script_String   := Dir_Get_Default_Drive;
  380.                         Script_IO_Error := Dir_Get_Current_Path( Script_String[1] ,
  381.                                                                  Script_String_2 );
  382.                         Script_Variables^[Script_Integer_1].Var_Value^ := Script_String;
  383.                         IF ( Script_IO_Error <> 0 ) THEN
  384.                            Script_String_2[0] := #0;
  385.                         Script_Variables^[Script_Integer_2].Var_Value^ := Script_String_2;
  386.                      END;
  387.                      GOTO LEndCase;
  388.  
  389.       LGetVarSy   :  GOTO LEndCase;
  390.  
  391.       LGossipSy   :  BEGIN
  392.                         Toggle_Option( 'Gossip mode', Gossip_Mode_On );
  393.                         Done := TRUE;
  394.                         IF Gossip_Mode_On THEN
  395.                            BEGIN
  396.                               Saved_Gossip_Term   := Terminal_To_Emulate;
  397.                               Terminal_To_Emulate := Gossip;
  398.                            END
  399.                         ELSE
  400.                            BEGIN
  401.                               Terminal_To_Emulate := Saved_Gossip_Term;
  402.                            END;
  403.                         GOTO LEndCase;
  404.                      END;
  405.  
  406.       LGoToSy     :  Script_Buffer_Pos := PRED( Script_Integer_1 );
  407.                      GOTO LEndCase;
  408.  
  409.       LGoToXYSy   :  GoToXY( Script_Integer_1, Script_Integer_2 );
  410.                      GOTO LEndCase;
  411.  
  412.       LHangUpSy   :  BEGIN (* Hang-up Phone *)
  413.  
  414.                         Save_Partial_Screen( Saved_Screen, 10, 10, 60, 15 );
  415.  
  416.                         Draw_Menu_Frame( 10, 10, 60, 15, Menu_Frame_Color,
  417.                                          Menu_Title_Color, Menu_Text_Color,
  418.                                          '' );
  419.  
  420.                         WRITELN;
  421.                         WRITELN('*** Hanging up the phone ***');
  422.  
  423.                                    (* Hang up the phone *)
  424.  
  425.                         HangUpPhone;
  426.  
  427.                         IF Async_Carrier_Detect THEN
  428.                            WRITELN('*** Phone not hung up, try again ***')
  429.                         ELSE
  430.                            BEGIN
  431.                               WRITELN('*** Phone hung up ***');
  432.                               Write_Log('Phone hung up', FALSE , FALSE );
  433.                            END;
  434.  
  435.                         DELAY( Two_Second_Delay );
  436.  
  437.                         Restore_Screen( Saved_Screen );
  438.  
  439.                         Reset_Global_Colors;
  440.                         GOTO LEndCase;
  441.  
  442.                      END   (* Hang-up Phone *);
  443.  
  444.       LHostSy     :  BEGIN (* Set host mode *)
  445.                         Done                := TRUE;
  446.                         Saved_Gossip_Term   := Terminal_To_Emulate;
  447.                         Terminal_To_Emulate := HostMode;
  448.                         GOTO LEndCase;
  449.                      END   (* Set host mode *);
  450.  
  451.  
  452.       LIfConSy    :  Do_Simple_If( Async_Carrier_Detect );
  453.                      GOTO LEndCase;
  454.  
  455.       LIfDialSy   :  Do_Simple_If( Script_Dialed );
  456.                      GOTO LEndCase;
  457.  
  458.       LIfEofSy    :  GOTO LEndCase;
  459.  
  460.       LIfExistsSy :  BEGIN
  461.                              (*$I-*)
  462.                         ASSIGN( F , Script_String );
  463.                         RESET ( F );
  464.                              (*$I+*)
  465.                         I := Int24Result;
  466.                              (*$I-*)
  467.                         CLOSE ( F );
  468.                              (*$I+*)
  469.                         J := Int24Result;
  470.  
  471.                         Do_Simple_If( ( I = 0 ) );
  472.                         GOTO LEndCase;
  473.  
  474.                      END;
  475.  
  476.       LIfFoundSy  :  Do_Simple_If( Script_Wait_Found );
  477.                      GOTO LEndCase;
  478.  
  479.       LIfLocStrSy :  BEGIN
  480.  
  481.                         IF ( LENGTH( Script_Reply  ) > 0 ) AND
  482.                            ( LENGTH( Script_String ) > 0 ) THEN
  483.                            Script_Reply_Found :=
  484.                               ( POS( Script_Reply , Script_String ) > 0 );
  485.  
  486.                         Do_Simple_If( Script_Reply_Found );
  487.                         GOTO LEndCase;
  488.  
  489.                      END;
  490.  
  491.       LIfOKSy     :  Do_Simple_If( Script_IO_Error <> 0 );
  492.                      GOTO LEndCase;
  493.  
  494.       LIfOpSy     :  BEGIN
  495.                         Execute_Stack( 0 );
  496.                         I := ( ORD( Script_Variables^[0].Var_Value^[2] ) SHL 8 ) OR
  497.                                ORD( Script_Variables^[0].Var_Value^[1] );
  498. {
  499.                         IF Debug_Mode THEN
  500.                            Debug_Write('---> IF returns ' + ITOS( I ) );
  501. }
  502.                         IF ( ( I AND 1 ) = 1 ) THEN
  503.                            Script_Buffer_Pos := PRED( Script_Integer_2 )
  504.                         ELSE
  505.                            Script_Buffer_Pos := PRED( Script_Integer_3 );
  506.                         GOTO LEndCase;
  507.                      END;
  508.  
  509.       LIfRemStrSy :  BEGIN
  510.  
  511.                         IF ( LENGTH( Script_Remote_Reply ) > 0 ) AND
  512.                            ( LENGTH( Script_String       ) > 0 ) THEN
  513.                            Script_Remote_Reply_OK :=
  514.                               ( POS( Script_Remote_Reply , Script_String ) > 0 );
  515.  
  516.                         Do_Simple_If( Script_Remote_Reply_OK );
  517.                         GOTO LEndCase;
  518.  
  519.                      END;
  520.  
  521.       LInfoSy     :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  522.                         Display_Help( FALSE );
  523.                      GOTO LEndCase;
  524.  
  525.       LInputSy    :  BEGIN
  526.                         WRITE( Script_String );
  527.                         Script_Reply[0] := #0;
  528.                         Read_Edited_String( Script_Reply );
  529.                         Script_Reply_Found := FALSE;
  530.                         IF ( Script_Integer_1 > 2 ) THEN
  531.                            BEGIN
  532.                               Script_Variables^[Script_Integer_1].Var_Value^ :=
  533.                                  Script_Reply;
  534. {
  535.                               IF Debug_Mode THEN
  536.                                  Debug_Write('   --> Variable read into is #' +
  537.                                        ITOS( Script_Integer_1 ) + ' = ' +
  538.                                        Script_Variables^[Script_Integer_1].Var_Name );
  539. }
  540.                            END;
  541.                         GOTO LEndCase;
  542.                      END;
  543.  
  544.       LInsLineSy  :  InsLine;
  545.                      GOTO LEndCase;
  546.  
  547.       LKeyDefSy   :  Define_Key( Script_String , Script_String_2 );
  548.                      GOTO LEndCase;
  549.  
  550.       LKeyFlushSy :  WHILE ( KeyPressed ) DO
  551.                         Read_Kbd( Ch );
  552.                      GOTO LEndCase;
  553.  
  554.       LKeySendSy  :  IF ( Key_No <> Command_Key ) THEN
  555.                         Handle_Function_Key( CHR( Key_No ) )
  556.                      ELSE
  557.                         BEGIN
  558.                            IF MyLoadOverlay( 0 , PT4SCRI, 'PT4SCRI.CHN' ) THEN
  559.                               Process_Script( '' , 'K' );
  560.                         END;
  561.                      GOTO LEndCase;
  562.  
  563.       LKeySy      :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  564.                         Set_Input_Keys( Script_String );
  565.                      GOTO LEndCase;
  566.  
  567.       LLogSy      :  BEGIN
  568.                         Toggle_Option('List session on printer', Printer_On );
  569.                         Alter_Status := TRUE;
  570.                      END;
  571.                      GOTO LEndCase;
  572.  
  573.       LMessageSy  :  BEGIN
  574.                         Script_String := Read_Ctrls( Script_String ) +
  575.                                          CHR( CR ) + CHR( LF );
  576.                         FOR I := 1 TO LENGTH( Script_String ) DO
  577.                            IF Use_Dos_Con_Output THEN
  578.                               Display_Character_Through_DOS( Script_String[I] )
  579.                            ELSE
  580.                               Display_Character( Script_String[I] );
  581.                      END;
  582.                      GOTO LEndCase;
  583.  
  584.       LMenuSy     :  BEGIN
  585.                                    (* Display menu *)
  586.  
  587.                         Menu_Display_Choices( Script_Menu_Holder^ );
  588.  
  589.                                    (* Get choice *)
  590.  
  591.                         I := Menu_Get_Choice( Script_Menu_Holder^ , Erase_Menu );
  592.  
  593.                         MOVE( I , Script_Variables^[Script_Integer_1].Var_Value^[1], 2 );
  594.  
  595.                         DISPOSE( Script_Menu_Holder );
  596.  
  597.                         GOTO LEndCase;
  598.  
  599.                      END;
  600.  
  601.       LMuteSy     :  BEGIN
  602.                         Toggle_Option('Silent Mode', Silent_Mode );
  603.                         Menu_Set_Beep( NOT Silent_Mode );
  604.                         GOTO LEndCase;
  605.                      END;
  606.  
  607.       LOpenSy     :  BEGIN
  608.  
  609.                         IF ( ( Script_Integer_1 < 1 ) OR
  610.                              ( Script_Integer_1 > MaxScriptOpenFiles ) ) THEN
  611.                            BEGIN
  612.                               Script_IO_Error := 999;
  613.                               GOTO LEndCase;
  614.                            END;
  615.  
  616.                         IF Script_File_Used[Script_Integer_1] THEN
  617.                            BEGIN
  618.                                  (*$I-*)
  619.                               CLOSE( Script_File_List[Script_Integer_1]^.F );
  620.                                  (*$I+*)
  621.                               DISPOSE( Script_File_List[Script_Integer_1] );
  622.                            END;
  623.  
  624.                         NEW( Script_File_List[Script_Integer_1] );
  625.  
  626.                         Script_File_Used[Script_Integer_1] := TRUE;
  627.  
  628.                         WITH Script_File_List[Script_Integer_1]^ DO
  629.                            BEGIN
  630.  
  631.                               ReadOnly  := ( Script_Integer_2 = 0 );
  632.                               EOF_Seen  := FALSE;
  633.  
  634.                                  (*$I-*)
  635.                               ASSIGN( F , Script_String );
  636.  
  637.                               CASE Script_Integer_2 OF
  638.                                  0: BEGIN
  639.                                        ASSIGN( F , Script_String );
  640.                                        RESET  ( F );
  641.                                        Script_IO_Error := INT24Result;
  642.                                     END;
  643.                                  1: BEGIN
  644.                                        ASSIGN( F , Script_String );
  645.                                        REWRITE( F );
  646.                                        Script_IO_Error := INT24Result;
  647.                                     END;
  648.                                  2: Flag := Open_For_Append( F,
  649.                                                              Script_String,
  650.                                                              Script_IO_Error );
  651.                               END (* CASE *);
  652.  
  653.                                  (*$I+*)
  654.  
  655.                               Opened := ( Script_IO_Error = 0 );
  656.  
  657.                            END;
  658.  
  659.                         GOTO LEndCase;
  660.  
  661.                      END;
  662.  
  663.       LGetParamSy :
  664.       LSetParamSy :
  665.       LParamSy    :  BEGIN
  666.                         T_Type              := Terminal_To_Emulate;
  667.                         IF MyLoadOverlay( 0 , PT4SETP, 'PT4SETP.CHN' ) THEN
  668.                            Flag   := Set_Params( FALSE , Use_Script );
  669.                         Done                := ( Terminal_To_Emulate <> T_Type );
  670.                         Alter_Status        := TRUE;
  671.                         GOTO LEndCase;
  672.                      END;
  673.  
  674.       LQuitSy     :  BEGIN (* Quit *)
  675.  
  676.                         Save_Partial_Screen( Saved_Screen, 10, 10, 55, 13 );
  677.  
  678.                         Draw_Menu_Frame( 10, 10, 55, 13, Menu_Frame_Color,
  679.                                          Menu_Title_Color, Menu_Text_Color,
  680.                                          '' );
  681.  
  682.                         IF Script_File_Mode THEN
  683.                            BEGIN
  684.                               IF Script_Integer_1 = 0 THEN
  685.                                  Script_File_Mode :=
  686.                                     NOT YesNo('Stop running current script (Y/N) ? ')
  687.                               ELSE
  688.                                  BEGIN
  689.                                     Script_File_Mode    := FALSE;
  690.                                     Script_File_Name[0] := #0;
  691.                                     Done                := TRUE;
  692.                                  END;
  693.                               IF ( NOT Script_File_Mode ) THEN
  694.                                  Clear_Script_Variables;
  695.                               Alter_Status := TRUE;
  696.                            END
  697.                         ELSE IF ( When_Mode OR When_Drop_Mode ) THEN
  698.                            BEGIN
  699.                               When_Mode :=
  700.                                  NOT YesNo('Stop WHEN and WHENDROP processing (Y/N) ? ');
  701.                               When_Drop_Mode := When_Mode;
  702.                               IF ( NOT When_Mode ) THEN
  703.                                  BEGIN
  704.                                     Script_When_Text      [0] := #0;
  705.                                     Script_When_Reply_Text[0] := #0;
  706.                                     Script_When_Drop_Text [0] := #0;
  707.                                  END;
  708.                            END
  709.                         ELSE
  710.                            Done := YesNo('Are you sure you want to quit (Y/N) ? ');
  711.  
  712.                         Restore_Screen( Saved_Screen );
  713.                         Reset_Global_Colors;
  714.  
  715.                         PibTerm_Done := Done;
  716.                         GOTO LEndCase;
  717.  
  718.                      END;
  719.  
  720.       LReadLnSy   : IF ( Script_Integer_1 = 0 ) THEN
  721.                        BEGIN
  722.                           READLN( Script_Variables^[Script_Integer_2].Var_Value^ );
  723.                           Script_IO_Error := INT24Result;
  724.                        END
  725.                     ELSE IF Script_File_Used[Script_Integer_1] THEN
  726.                        WITH Script_File_List[Script_Integer_1]^ DO
  727.                           BEGIN
  728.                              IF ( Opened AND ReadOnly AND ( NOT EOF_Seen ) ) THEN
  729.                                 BEGIN
  730.                                       (*$I-*)
  731.                                    READLN( F ,
  732.                                          Script_Variables^[Script_Integer_2].Var_Value^ );
  733.                                       (*$I+*)
  734.                                    Script_IO_Error := INT24Result;
  735.                                    IF ( NOT EOF_Seen ) THEN
  736.                                       EOF_Seen := EOF( F );
  737.                                 END
  738.                              ELSE
  739.                                 Script_IO_Error := 999;
  740.                           END;
  741.                      GOTO LEndCase;
  742.  
  743.       LReadSy     : BEGIN
  744. {
  745.                     Write_Log('U='+CHR( ORD('0') + Script_Integer_1 ), FALSE,
  746.                               FALSE);
  747.                     Write_Log('N='+CHR( ORD('0') + Script_Integer_3 ), FALSE,
  748.                               FALSE);
  749. }
  750.                     IF Script_File_Used[Script_Integer_1] THEN
  751.                        WITH Script_File_List[Script_Integer_1]^ DO
  752.                           BEGIN
  753.                              Flag := ( Script_Integer_1 = 0 );
  754.                              IF ( Opened AND ( Flag OR ReadOnly ) ) THEN
  755.                                 Read_Chars( F,
  756.                                             Script_Variables^[Script_Integer_2].Var_Value^,
  757.                                             Script_Integer_3,
  758.                                             EOF_Seen,
  759.                                             Flag )
  760.                              ELSE
  761.                                 Script_IO_Error := 999;
  762.                           END;
  763.                      END;
  764.                      GOTO LEndCase;
  765.  
  766.       LReceiveSy  :  BEGIN
  767.  
  768.                         IF LENGTH( Script_String ) > 0 THEN
  769.                            FileName        := Script_String;
  770.  
  771.                         IF ( Script_Integer_1 > 0 ) THEN
  772.                            BEGIN
  773.                               Trans_Type      := Transfers[ Script_Integer_1 ];
  774.                               Script_Transfer := TRUE;
  775.                            END
  776.                         ELSE
  777.                            Trans_Type := None;
  778.  
  779.                         PibDownLoad( Trans_Type );
  780.  
  781.                         Script_Transfer := FALSE;
  782.  
  783.                         GOTO LEndCase;
  784.  
  785.                      END;
  786.  
  787.       LResetSy    :  Script_Buffer_Pos := 0;
  788.                      GOTO LEndCase;
  789.  
  790.       LReturnSy   :  IF ( Script_Call_Depth > 0 ) THEN
  791.                         WITH Script_Call_Stack[Script_Call_Depth] DO
  792.                            BEGIN
  793.                               IF ( Proc_Parameter_Count > 0 ) THEN
  794.                                  DISPOSE( Proc_Parameters );
  795.                               Script_Buffer_Pos    := Return_Addr;
  796.                               Proc_Parameters      := Proc_Param;
  797.                               Proc_Parameter_Got   := Proc_Got;
  798.                               Proc_Parameter_Count := Proc_Count;
  799.                               Script_Call_Depth    := PRED( Script_Call_Depth );
  800. {
  801.                            IF Debug_Mode THEN
  802.                               Debug_Write('---> Ret from proc to location ' +
  803.                                           ITOS( Script_Buffer_Pos ) );
  804. }
  805.                            END;
  806.                      GOTO LEndCase;
  807.  
  808.       LRInputSy   :  Remote_Input;
  809.                      GOTO LEndCase;
  810.  
  811.       LExecuteSy  :
  812.       LExeNewSy   :
  813.       LScriptSy   :  BEGIN
  814.                         IF ( LENGTH( Script_String ) > 0 ) THEN
  815.                            Ch := Script_String[1]
  816.                         ELSE
  817.                            Ch := ' ';
  818.                         IF MyLoadOverlay( 0 , PT4SCRI, 'PT4SCRI.CHN' ) THEN
  819.                            Process_Script( Script_String_2 , Ch );
  820.                         Alter_Status := TRUE;
  821.                         GOTO LEndCase;
  822.                      END;
  823.  
  824.       LSDumpSy    :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  825.                         Do_Screen_Dump;
  826.                      GOTO LEndCase;
  827.  
  828.       LSendSy     :  BEGIN
  829.  
  830.                         IF LENGTH( Script_String ) > 0 THEN
  831.                            FileName        := Script_String;
  832.  
  833.                         IF ( Script_Integer_1 > 0 ) THEN
  834.                            BEGIN
  835.                               Trans_Type      := Transfers[ Script_Integer_1 ];
  836.                               Script_Transfer := TRUE;
  837.                            END
  838.                         ELSE
  839.                            Trans_Type := None;
  840.  
  841.                         PibUpLoad( Trans_Type );
  842.  
  843.                         Script_Transfer := FALSE;
  844.  
  845.                         GOTO LEndCase;
  846.  
  847.                      END;
  848.  
  849.       LSetSy      :  BEGIN
  850. {
  851.                         IF Debug_Mode THEN
  852.                            Debug_Write('---> Setting variable # ' +
  853.                                    ITOS( Script_Integer_1 ) + ', is ' +
  854.                                    Script_Variables^[Script_Integer_1].Var_Name );
  855. }
  856.                         Execute_Stack( Script_Integer_1 );
  857.  
  858.                         GOTO LEndCase;
  859.                      END;
  860.  
  861.       LSetVarSy   :  GOTO LEndCase;
  862.  
  863.       LSTextSy    :  BEGIN
  864.                         Send_Function_Key( Read_Ctrls( Script_String ) );
  865.                         Script_String[0] := #0;
  866.                         GOTO LEndCase;
  867.                      END;
  868.  
  869.       LTextSy     :  BEGIN
  870.                         Async_Send_String( Script_String );
  871.                         Script_String[0] := #0;
  872.                         GOTO LEndCase;
  873.                      END;
  874.  
  875.       LTimersSy   :  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  876.                         Display_Timers;
  877.                      GOTO LEndCase;
  878.  
  879.       LTranslateSy:  IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  880.                         Set_Translate_Table( Script_String );
  881.                      GOTO LEndCase;
  882.  
  883.       LViewSy     :  IF Review_On THEN
  884.  
  885.                         IF ( Review_Head > 0 ) THEN
  886.                            BEGIN
  887.                               IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
  888.                                  Review_Captured_Text;
  889.                            END
  890.                         ELSE
  891.                            BEGIN
  892.  
  893.                               Save_Partial_Screen( Saved_Screen, 10, 10, 60, 14 );
  894.  
  895.                               Draw_Menu_Frame( 10, 10, 60, 14, Menu_Frame_Color,
  896.                                                Menu_Title_Color,
  897.                                                Menu_Text_Color, '' );
  898.  
  899.                               WRITE('Review buffer empty.');
  900.  
  901.                               DELAY( Two_Second_Delay );
  902.  
  903.                               Restore_Screen( Saved_Screen );
  904.  
  905.                               Reset_Global_Colors;
  906.  
  907.                            END
  908.                         ELSE
  909.                      BEGIN
  910.                         Save_Partial_Screen( Saved_Screen, 10, 10, 60, 14 );
  911.  
  912.                         Draw_Menu_Frame( 10, 10, 60, 14, Menu_Frame_Color,
  913.                                          Menu_Title_Color,
  914.                                          Menu_Text_Color, '' );
  915.  
  916.                         WRITE('Review buffer not active.');
  917.  
  918.                         DELAY( Two_Second_Delay );
  919.  
  920.                         Restore_Screen( Saved_Screen );
  921.  
  922.                         Reset_Global_Colors;
  923.                      END;
  924.                      GOTO LEndCase;
  925.  
  926.       LWaitSy     : BEGIN
  927.  
  928.                        TimeW := COPY( Script_String, 1, 8 );
  929.  
  930.                        Save_Partial_Screen( Local_Save, 10, 10, 60, 14 );
  931.  
  932.                        Draw_Menu_Frame( 10, 10, 60, 14, Menu_Frame_Color,
  933.                                         Menu_Title_Color,
  934.                                         Menu_Text_Color,
  935.                                         'Wait For Specified Time' );
  936.  
  937.                        WRITELN('Waiting for:  ',TimeW);
  938.                        WRITE  ('Current time: ');
  939.  
  940.                        I         := WhereY;
  941.                        TimeN[0]  := #0;
  942.                        ESC_Found := FALSE;
  943.  
  944.                        REPEAT
  945.                           TimeO := TimeN;
  946.                           TimeN := TimeString( TimeOfDay , Military_Time );
  947.                           IF ( TimeN <> TimeO ) THEN
  948.                              BEGIN
  949.                                 GoToXY( 15 , I );
  950.                                 WRITE( TimeN );
  951.                              END;
  952.                           IF KeyPressed THEN
  953.                              BEGIN
  954.                                 READ( Kbd, Ch );
  955.                                 IF ORD( Ch ) = ESC THEN
  956.                                    BEGIN
  957.                                       ESC_Found := TRUE;
  958.                                       IF KeyPressed THEN
  959.                                          READ( Kbd, Ch );
  960.                                    END;
  961.                              END;
  962.                        UNTIL( TimeN = TimeW ) OR ESC_Found;
  963.  
  964.                        Restore_Screen( Local_Save );
  965.                        Reset_Global_Colors;
  966.  
  967.                        GOTO LEndCase;
  968.                     END;
  969.  
  970.       LWhereXYSy  : BEGIN
  971.                        I := WhereX;
  972.                        J := WhereY;
  973.                        MOVE( I , Script_Variables^[Script_Integer_1].Var_Value^[1], 2 );
  974.                        MOVE( J , Script_Variables^[Script_Integer_2].Var_Value^[1], 2 );
  975.                     END;
  976.                     GOTO LEndCase;
  977.  
  978.       LWriteLnSy  : IF ( Script_Integer_1 = 0 ) THEN
  979.                        WRITELN( Script_String )
  980.                     ELSE IF Script_File_Used[Script_Integer_1] THEN
  981.                        WITH Script_File_List[Script_Integer_1]^ DO
  982.                           BEGIN
  983.                              IF ( Opened AND ( NOT ReadOnly ) ) THEN
  984.                                 BEGIN
  985.                                       (*$I-*)
  986.                                    WRITELN( F , Script_String );
  987.                                       (*$I+*)
  988.                                    Script_IO_Error := INT24Result;
  989.                                 END
  990.                              ELSE
  991.                                 Script_IO_Error := 999;
  992.                           END;
  993.                     GOTO LEndCase;
  994.  
  995.       LWriteSy    : IF ( Script_Integer_1 = 0 ) THEN
  996.                        WRITE( Script_String )
  997.                     ELSE IF Script_File_Used[Script_Integer_1] THEN
  998.                        WITH Script_File_List[Script_Integer_1]^ DO
  999.                           BEGIN
  1000.                              IF ( Opened AND ( NOT ReadOnly ) ) THEN
  1001.                                 BEGIN
  1002.                                       (*$I-*)
  1003.                                    WRITE( F , Script_String );
  1004.                                       (*$I+*)
  1005.                                    Script_IO_Error := INT24Result;
  1006.                                 END
  1007.                              ELSE
  1008.                                 Script_IO_Error := 999;
  1009.                           END;
  1010.                     GOTO LEndCase;
  1011.  
  1012.       LWriteLogSy : Write_Log( Script_String , FALSE , FALSE );
  1013.                     GOTO LEndCase;
  1014.  
  1015.       LZapVarSy   : Zap_Script_Variables( Script_Integer_1 , Script_Integer_2 );
  1016.                     GOTO LEndCase;
  1017.  
  1018. {
  1019.       ELSE        ;
  1020.  
  1021.    END (* CASE *);
  1022. }
  1023. LEndCase: ;
  1024.                                    (* Update status display if parameters  *)
  1025.                                    (* changed.                             *)
  1026.  
  1027.    Do_Script_Tests := Waitstring_Mode OR When_Mode OR
  1028.                       WaitCount_Mode  OR WaitQuiet_Mode OR
  1029.                       Script_Learn_Mode;
  1030.  
  1031.    IF Reverse_Status_Colors THEN
  1032.       Status_Line_Attr := ( ForeGround_Color AND 7 ) SHL 4 + BackGround_Color
  1033.    ELSE
  1034.       Status_Line_Attr := ( Status_BackGround_Color AND 7 ) SHL 4 + Status_ForeGround_Color;
  1035.  
  1036.    Do_Status_Line     := Show_Status_Line AND
  1037.                          ( NOT Use_Dos_Con_Output ) AND
  1038.                          ( NOT Graphics_Terminal_Mode );
  1039.  
  1040.    Do_Status_Time     := Do_Status_Line AND Show_Status_Time;
  1041.  
  1042.                                    (* If any status stuff changed, *)
  1043.                                    (* rewrite the status line      *)
  1044.    IF Do_Status_Line THEN
  1045.       IF ( Alter_Status OR Reset_Comm_Port ) THEN
  1046.          BEGIN
  1047.             IF ( WhereY = Max_Screen_Line ) THEN
  1048.                BEGIN
  1049.                   MoveToXY( WhereX , Max_Screen_Line - 1 );
  1050.                   Do_Status_Line := FALSE;
  1051.                   Scroll( 1, Max_Screen_Line, 1, Max_Screen_Col, 1,
  1052.                           ForeGround_Color, BackGround_Color );
  1053.                   Do_Status_Line := TRUE;
  1054.                END;
  1055.             Set_Status_Line_Name( Short_Terminal_Name );
  1056.             Write_To_Status_Line( Status_Line_Name, 1 );
  1057.          END
  1058.       ELSE (* Leave status line as is *)
  1059.    ELSE
  1060.       IF( Save_Do_Status_Line ) THEN
  1061.          BEGIN (* Remove status line that was there before *)
  1062.  
  1063.             Status_Line_Attr   := ( BackGround_Color AND 7 ) SHL 4 +
  1064.                                   ForeGround_Color;
  1065.  
  1066.             Do_Status_Line := TRUE;
  1067.  
  1068.             Write_To_Status_Line( DUPL( ' ' , Max_Screen_Col ), 1 );
  1069.  
  1070.             Do_Status_Line := FALSE;
  1071.  
  1072.          END;
  1073.  
  1074.    Reset_Comm_Port := FALSE;
  1075.  
  1076. END   (* Execute_Command *);
  1077.